package com.fengke.dao.division.impl;

import java.sql.SQLException;
import java.util.List;

import com.fengke.dao.BaseDaoIbatis;
import com.fengke.dao.division.DivisionManager;
import com.fengke.dao.model.DepartureModel;
import com.fengke.dao.model.DestinationModel;

public class DivisionManagerImpl extends BaseDaoIbatis implements DivisionManager {

	@SuppressWarnings("unchecked")
	public List<DepartureModel> researchDepartureModelList(DepartureModel departureModel, int offset, int limit) throws SQLException {
		return this.getSqlMapClientTemplate().queryForList("DivisionRepository.researchDepartureModelList", departureModel, offset, limit);
	}

	@SuppressWarnings("unchecked")
	public List<DestinationModel> researchDestinationModelList(DestinationModel destinationModel, int offset, int limit) throws SQLException {
		return this.getSqlMapClientTemplate().queryForList("DivisionRepository.researchDestinationModelList", destinationModel, offset, limit);
	}

	@Override
	public Long createDeparture(DepartureModel departureModel) throws SQLException {
		return (Long) this.getSqlMapClientTemplate().insert("DivisionRepository.createDeparture", departureModel);
	}

	@Override
	public void updateDepartureById(DepartureModel departureModel) throws SQLException {
		this.getSqlMapClientTemplate().update("DivisionRepository.updateDepartureById", departureModel);
	}

	@Override
	public Long createDestination(DestinationModel destinationModel) throws SQLException {
		return (Long) this.getSqlMapClientTemplate().insert("DivisionRepository.createDestination", destinationModel);
	}

	@Override
	public void updateDestinationById(DestinationModel destinationModel) throws SQLException {
		this.getSqlMapClientTemplate().update("DivisionRepository.updateDestinationById", destinationModel);
	}

	@Override
	public void deleteDepartureByIds(List<String> list) throws SQLException {
		this.getSqlMapClientTemplate().delete("DivisionRepository.deleteDepartureByIds", list);
	}

	@Override
	public void deleteDestinationByIds(List<String> list) throws SQLException {
		this.getSqlMapClientTemplate().delete("DivisionRepository.deleteDestinationByIds", list);
	}
}
